<?php
ob_start();
if(!isset($_SESSION)) 
	{ 
		session_start(); 
	}
require_once('calendar/classes/tc_calendar.php');
include 'operations/connection.php';

include "generallibraries/funcs.php";
$hamsort=" where ac_customer.Activest=1 order by ac_customer.CustomerName desc";
$sqlCustomer = generalFunctions::listCustomer("ac_customer.CustomerID, ac_customer.CustomerName",$hamsort);
$mangCustomer=mysql_query($sqlCustomer);

if($_REQUEST['action']){
	$action=$_REQUEST['action'];
	$id=$_REQUEST['idapprovedoc'];
	if($_REQUEST['action']=="editform" || $_REQUEST['action']=="my_declined" || $_REQUEST['action']=="my_sending"){
		
		$sql="select Tile,EmployeePerforment,Location,TotalTime,TripDate,Description,comment,Content from approvedoc where IDApproveDoc='".$id."'";
		$mangnoidung= mysql_fetch_assoc(mysql_query($sql));
		$fromdate = $mangnoidung[TripDate];
		$ftitle=$mangnoidung[Tile];
		$fdescription=$mangnoidung[Description];
		$fcontent=$mangnoidung[Content];
		$fcomment=$mangnoidung[comment];
		$femperform=$mangnoidung[EmployeePerforment];
		$flocation=$mangnoidung[Location];
		$ftotaltime=$mangnoidung[TotalTime];
		$querybuy = mysql_query("select * from buying_document where document_id = '$id'");
		if(count($querybuy)>0){
			$listpurchase=array();
			while ($row = mysql_fetch_array($querybuy))
			{
				$listpurchase[]=array(0,$row[name],$row[company],$row[amount],$row[price],$row[vat],$row[total]);
			}
			$_SESSION['listpurchase']=$listpurchase;
		}else{
			$listpurchase=array();
			$listpurchase[]=array(0,"","",0,0,0,0);
			$_SESSION['listpurchase']=$listpurchase;
		}
		//attach
		$listattachedit = mysql_query('select id, approveid, filepath, filereal, filename, filetype, filesize, createdate from approve_attach where approveid='.$id);
			
	}else if($_REQUEST['action']=="newform"){
		$fromdate=date("Y-m-d");
		$ftitle="";
		$fdescription="";
		$fcontent="";
		$fcomment="";
		$femperform="";
		$flocation="";
		$ftotaltime="";
		
		$listpurchase=array();
		$listpurchase[]=array(0,"","",0,0,0,0);
		$_SESSION['listpurchase']=$listpurchase;
	}
}

?>

<!-- attach -->
<script type="text/javascript" src="attach/js/webtoolkit.aim.js"></script>
<script type="text/javascript" src="attach/js/myattach.js"></script>
<link
	href="attach/css/myattach.css" rel="stylesheet" type="text/css" />
<!-- end attach -->
<script type="text/javascript">
function startCallback() {
	// viết code khi click nút upload và bắt đầu upload.
	$('#attachloading').append ('<?=$l_uploading?>');
	return true;
}


</script>

<link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" />
<script type="text/javascript" src="js/jquery.autocomplete.js"></script>
<link
	href="css/style.css" rel="stylesheet" type="text/css" />
<link
	href="calendar/calendar.css" rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="admin/ckeditor_351/ckeditor.js"></script>
<script type="text/javascript"
	src="admin/ckfinder/ckfinder.js"></script>
<style>
.cke_contents {
	height: 400px !important;
}
a[title="Browse Server"]{
	display:none !important;
}
a[title="Duyệt trên máy chủ"]{
	display:none !important;
}
a[title="서버 보기"]{
	display:none !important;
}
a[title="Link"]{
	display:none !important;
}
a[title="Liên kết"]{
	display:none !important;
}
a[title="링크"]{
	display:none !important;
}
a[title="Advanced"]{
	display:none !important;
}
a[title="Tab mở rộng"]{
	display:none !important;
}
a[title="자세히"]{
	display:none !important;
}
tr td.cke_bottom{
	display:none !important;
}
</style>
<script type="text/javascript">
	$(document).ready(function() {
		  var editor = CKEDITOR.replace("n222",{language:"<?php $lang_current = $_SESSION['lang'];
if (isset($lang_current)) {
	if ($lang_current=='VN'){
		echo 'vi';
	}else if ($lang_current=='KR') {
		echo 'ko';
	}
	else{
		echo 'en';
	}
}
else{
	echo 'en';
} ?>", height:'100%', width:'100%'});
		    CKFinder.setupCKEditor(editor, 'admin/ckfinder') ;
	});
</script>
<style type="text/css">
#content_menu_expand{
	position:absolute; 
	right:-5px;
	top:20px;
	z-index:999;
	background-color: #ffffff;
	-moz-border-radius: 7px;
	-webkit-border-radius: 7px;
	color: #000000;
	width:300px; 
	max-height:180px;
	overflow:auto;
}
.passul{padding-left:0; border:1px solid black}
.bgkhac {background: #eee;}
.passul ul li {color:#474747; font-size:12px;padding: 5px 0;padding-left:5px;}
.passul ul li:hover { background: #0A246A;color:white;text-decoration: none;}
</style>
<script type="text/javascript">
$(document).ready(function(){
	$("#inputString").autocomplete("operations/rpc.php", {
		selectFirst: true
	});
	$('#content_menu_expand').hide();
	$(document).click(function() {
		$("#content_menu_expand").hide();
	});
	$('#content_menu_expand').click(function(e) {
		e.stopPropagation();
	});

	$('#menu_expand').click(function() {
		if ($('#content_menu_expand').is(":hidden")) {
			$('#content_menu_expand').show();
		}
		else {
			$('#content_menu_expand').hide();
		}
		return false;
	});
	$('#close_menu').click(function() {
		$('#content_menu_expand').hide();
		return false;
	});

	$("ul.menu_inside li a").hover(function() {
		$(this).parent().find("ul.subnav").slideDown(0).show();
		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp(0);
		});
	}).hover(function() {
		$(this).addClass("subhover");
	}, function(){
		$(this).removeClass("subhover");
	});
});
function ch(){
	if(document.f15.title.value==""){
		alert('<?=$l_titlemusthavedate?>');
		document.f15.title.focus();
		return false;
	}else{
		if(document.f15.inputString.value==""){
			alert('<?=$l_pleaseentercompanyname?>');
			document.f15.inputString.focus();
			return false;
		}
	}
}

function focusOnMyInputBox(e,ten){
    var x;
    if(window.event) // IE8 and earlier
    	{
    	x=e.keyCode;
    	}
    else if(e.which) // IE9/Firefox/Chrome/Opera/Safari
    	{
    	x=e.which;
    	}
	if(x==13){
		document.getElementById(ten).focus();
		return false;
	}else{
		return true;
	}
}
</script>
<script type="text/javascript">

function enterTable(e,value,count,co){
    var key = window.event ? e.keyCode : e.which;
    if (key == 13 || key == 8 || key == 46  || key == 37 || key == 39 || co == '0') {
		if(key==13){
			var i = 0;
			var j = 0;
			var listID = new Array();
			for(i = 1; i <= count;i++){
		        listID = listID.concat(["name"+i,"txtNumber"+i,"txtPrice"+i,"txtVat"+i]);	
			}
			if(value == listID[listID.length-1]){	
				document.getElementById("comment").focus();
				return false;			
			}else{
				for (j = 0; j < listID.length; j++){	
					if (listID[j] == value) {	
						if (j == listID.length - 1) {
							return false;
						}
						document.getElementById(listID[j + 1]).focus();
						document.getElementById(listID[j + 1]).select();
						return false; 
					}
				}
			}

			return false;
		}else

		return true;	
    } else if ( key < 48 || key > 57 ) {
        return false;
    }
    else return true;
				
}
</script>
<script type="text/javascript">
function addPurchase()
{

	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("purchase").innerHTML=xmlhttp.responseText;
										  }
									  }
	xmlhttp.open("GET","ajax/addPurchase.php?action=add",true);
	xmlhttp.send();
}
function delPurchase()
{

	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("purchase").innerHTML=xmlhttp.responseText;
										  }
									  }
	xmlhttp.open("GET","ajax/addPurchase.php?action=del",true);
	xmlhttp.send();
}

function checkPurchase(str)
{

	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("purchase").innerHTML=xmlhttp.responseText;
										  }
									  }
	xmlhttp.open("GET","ajax/addPurchase.php?action=check&id="+str,true);
	xmlhttp.send();
}

function chPricePurchase(str,str1)
{
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("vat"+str1).innerHTML=xmlhttp.responseText;
										    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
										    		xmlhttp1=new XMLHttpRequest();
										    	}else{// code for IE6, IE5
										    		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
										    	}
										    	xmlhttp1.onreadystatechange=function(){
										    										  if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
										    										    	document.getElementById("total"+str1).innerHTML=xmlhttp1.responseText;
										    										    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
										    										    		xmlhttp2=new XMLHttpRequest();
										    										    	}else{// code for IE6, IE5
										    										    		xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
										    										    	}
										    										    	xmlhttp2.onreadystatechange=function(){
										    										    										  if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
										    										    										    	document.getElementById("all").innerHTML=xmlhttp2.responseText;
										    										    										  }
										    										    	}
										    										    	xmlhttp2.open("GET","ajax/chTotalAllPurchase.php?action=chPrice&value="+str+"&id="+str1,true);

										    										    	xmlhttp2.send();
										    										  }
										    	}
										    	xmlhttp1.open("GET","ajax/chQuantityPurchase.php?action=chPrice&value="+str+"&id="+str1,true);

										    	xmlhttp1.send();
										    										    	
										  }
									  }
	if(str=='')
		str=0;
	else
		str=parseInt(str,10);
	document.getElementById("txtPrice"+str1).value=str;
	xmlhttp.open("GET","ajax/chPricePurchase.php?action=chPrice&value="+str+"&id="+str1,true);
	xmlhttp.send();



	

	
	
}
function chVatPurchase(str,str1)
{
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("price"+str1).innerHTML=xmlhttp.responseText;
										    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
										    		xmlhttp1=new XMLHttpRequest();
										    	}else{// code for IE6, IE5
										    		xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
										    	}
										    	xmlhttp1.onreadystatechange=function(){
										    										  if (xmlhttp1.readyState==4 && xmlhttp1.status==200){
										    										    	document.getElementById("total"+str1).innerHTML=xmlhttp1.responseText;
										    										    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
										    										    		xmlhttp2=new XMLHttpRequest();
										    										    	}else{// code for IE6, IE5
										    										    		xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
										    										    	}
										    										    	xmlhttp2.onreadystatechange=function(){
										    										    										  if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
										    										    										    	document.getElementById("all").innerHTML=xmlhttp2.responseText;
										    										    										  }
										    										    	}
										    										    	xmlhttp2.open("POST","ajax/chTotalAllPurchase.php?action=chVat&value="+str+"&id="+str1,true);

										    										    	xmlhttp2.send();
										    										  }
										    	}
										    	xmlhttp1.open("POST","ajax/chQuantityPurchase.php?action=chPrice&value="+str+"&id="+str1,true);

										    	xmlhttp1.send();
										  }
									  }
	if(str=='')
		str=0;
	else
		str=parseInt(str,10);
	document.getElementById("txtVat"+str1).value=str;
	xmlhttp.open("POST","ajax/chVatPurchase.php?action=chVat&value="+str+"&id="+str1,true);
	xmlhttp.send();



	
	
}
function chQuantityPurchase(str,str1)
{
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("total"+str1).innerHTML=xmlhttp.responseText;
										    	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
										    		xmlhttp2=new XMLHttpRequest();
										    	}else{// code for IE6, IE5
										    		xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
										    	}
										    	xmlhttp2.onreadystatechange=function(){
										    										  if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
										    										    	document.getElementById("all").innerHTML=xmlhttp2.responseText;
										    										  }
										    	}
										    	xmlhttp2.open("GET","ajax/chTotalAllPurchase.php?action=chTotal&value="+str+"&id="+str1,true);

										    	xmlhttp2.send();
										  }
									  }
	if(str=='')
		str=0;
	else
		str=parseInt(str,10);
	document.getElementById("txtNumber"+str1).value=str;
	xmlhttp.open("GET","ajax/chQuantityPurchase.php?action=chQuantity&value="+str+"&id="+str1,true);
	xmlhttp.send();


	
}
function chNamePurchase(str,str1)
{
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp2=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp2.onreadystatechange=function(){
										  if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
										    	document.getElementById("all").innerHTML=xmlhttp2.responseText;
										  }
	}
	xmlhttp2.open("GET","ajax/chTotalAllPurchase.php?action=chName&value="+str+"&id="+str1,true);

	xmlhttp2.send();
}
function chItemPurchase(str,str1)
{
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp2=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp2.onreadystatechange=function(){
						  if (xmlhttp2.readyState==4 && xmlhttp2.status==200){
						    	document.getElementById("all").innerHTML=xmlhttp2.responseText;
						  }
	}
	xmlhttp2.open("GET","ajax/chTotalAllPurchase.php?action=chItem&value="+encodeURIComponent(str)+"&id="+str1,true);
	xmlhttp2.send();
}

function chTotalAllPurchase(str,str1)
{

	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("all"+str1).innerHTML=xmlhttp.responseText;
										  }
									  }
	xmlhttp.open("GET","ajax/chTotalAllPurchase.php?action=chToaltal&value="+str+"&id="+str1,true);
	xmlhttp.send();
}
function clickCustomer(gt){
	document.getElementById("inputString").value=gt;
	$('#content_menu_expand').hide();
}
</script>
<div class="nav_top">
       		<div class="nav_tit"><?php echo $l_business_trip_report?></div>     
            <div class="rehome"><a href="mainPhone.php"><?php echo $l_menu?></a></div>       
       	</div>
<form method="post" onsubmit="editor1.prepareSubmit();"
	name="f15" action="newform-handle.php">

	
	<input type="hidden" name='type' value="<?=$type?>" />
	<input type="hidden" name='action' value="<?=$action?>" />
	<input type="hidden" name='id' value="<?=$id?>" />
	<div class="main_content" style="min-height: 895px">
			<ul class="top_but" >
				<li>
				<?php if($action=="my_declined" || $action=="my_sending"){?>
					<a href="mydocument-list-mydocument-saved-content"><img src="images/back.png" alt="" /> </a>
				<?php }else{?>
					
				<?php if(isset($_REQUEST['page'])){?>
					<a href="<?=$_SERVER['HTTP_REFERER']?>&page=<?=$_REQUEST['page']?>"><img src="images/back.png" alt="" /> </a>
				<?php }else{?>
					<a href="<?=$_SERVER['HTTP_REFERER']?>"><img src="images/back.png" alt="" /> </a>
				<?php } 
				} ?>
				
				
					<p class="hidden" >
					<?=$l_back?>
					</p>
				</li>
				<li><input type="submit" name="Save" value="" onclick="return ch();" 
				style="background: url(images/save.png) no-repeat; width: 36px; height: 36px; border: none; position: absolute; top:0px; left:0px; right:0px; bottom:0px; margin: auto" />
				<p class="hidden">
				<?=$l_save?>
				</p></li>
				<li><input type="submit" name="Send" value="" onclick="return ch();" 
				style="background: url(images/send.png) no-repeat; width: 36px; height: 36px; border: none; position: absolute; top:0px; left:0px; right:0px; bottom:0px; margin: auto" />
				<p class="hidden" >
				<?=$l_send_document?>
				</p></li>
			<?php 
			
				if($_REQUEST['action']){
					if($_REQUEST['action']=="editform" || $_REQUEST['action']=="my_declined"){
						?>
						
						<li><input type="submit" name="Delete" value="" 
						style="background: url(images/deny.png) no-repeat; width: 36px; height: 36px; border: none; position: absolute; top:0px; left:0px; right:0px; bottom:0px; margin: auto" />
						<p class="hidden">
						<?=$l_delete?>
						</p></li>
						
						<?php 
					}
				}
			
			
			?>
			</ul>
            <table class="tcontent" cellpadding="5" cellspacing="0" style="width:100%">
            	<tr>
                	<td width="15%" class="col_left"><?php echo $l_title?></td>
                    <td colspan="3"><input type="text" id="title" name="title" onkeypress ="return focusOnMyInputBox(event,'employeeper');" style="height:24px; width:100%; border:1px solid #c4c0c9;line-height: 24px;"  value="<?php echo $ftitle?>"/></td>
                </tr>
                 <tr>
                	<td class="col_left" width="15%"><?php echo  $l_employee_performent?></td>
                  	<td colspan="3"><input type="text" id="employeeper" name="employeeper" onkeypress ="return focusOnMyInputBox(event,'location');" style="height:24px; width:100%; border:1px solid #c4c0c9;line-height: 24px;" value="<?php echo $femperform?>"/></td>
                </tr>
                <tr>
                	<td class="col_left" width="15%"><?php echo  $l_location?></td>
                  	<td colspan="3"><input type="text" id="location" name="location" onkeypress ="return focusOnMyInputBox(event,'totaltime');"  style="height:24px; width:100%; border:1px solid #c4c0c9;line-height: 24px;" value="<?php echo $flocation?>"/></td>
                </tr> 
                <tr>
                	<td class="col_left" width="15%"><?php echo  $l_total_time?></td>
                  	<td colspan="3"><input type="text" id="totaltime" onkeypress ="return focusOnMyInputBox(event,'description');"  name="totaltime" style="height:24px; width:100%; border:1px solid #c4c0c9;line-height: 24px;" value="<?php echo $ftotaltime?>"/></td>
                </tr>
                <tr>                	
           	      <td class="col_left" width="15%"><?php echo $l_trip_date?></td>
                  <td style="text-align:left"><div align="left">
				<?php
				$myCalendar1 = new tc_calendar("date1", true);
				$myCalendar1->setIcon("calendar/images/iconCalendar.gif");
				$d=split('-',$fromdate,3);
					
				$myCalendar1->setDate($d[2],$d[1],$d[0]);
				$myCalendar1->setPath("calendar/");
				$myCalendar1->setYearInterval(2010, 2015);
				$myCalendar1->dateAllow('2010-01-01', '2015-12-31');
				//$myCalendar1->setHeight(350);
				//$myCalendar1->autoSubmit(true, "form1");
				//$myCalendar1->setSpecificDate(array("2011-04-01", "2011-04-13", "2011-04-25"), 0, 'month');
				$myCalendar1->setOnChange("myChanged('test')");
				//$myCalendar->rtl = true;
				$myCalendar1->writeScript();
					
				//echo $myCalendar1->getDate();

				?>
					</div></td>       
                </tr>                 
                <tr>
                	<td class="col_left" width="15%"><?php echo $l_description?></td>
                  	<td colspan="3"><textarea rows="3" id="description" name="description" cols="5" style="width:100%; border:1px solid #c4c0c9"><?php echo $fdescription?></textarea></td>
                </tr>  
               	<tr>

				<td colspan="4">
					<textarea rows="" cols="" id="n222" class="n222" name="n222"  style="width: 100%"><?php echo $fcontent;?></textarea>
				<div align="left">
				<div style='float: left'>
				<a  onkeydown="return CKEDITOR.tools.callFunction(0, 12, event);"
						 id=cke_21 class="cke_off cke_button_image"
						   title=Image role=button tabIndex=-1 aria-labelledby=cke_21_label
						   onclick="CKEDITOR.tools.callFunction(17, this); return false;" href="javascript:void('Image')" ? unselectable="on" 
						   style="width: 50px;height:20px;background-color: blue">
							  <input class="buttonProject" type="button" style="margin: 5px 0;" value="Insert images" /> 
						  </a>
				</div>
				<div style='float: left;padding-top:2px;margin-left:20px'>
						  <?php include 'attach/attach.php';?>
						  </div>
				</div>
				</td>

			</tr>              
            </table>

          
          <table id="themcongty" style="padding-top: 20px; ">
		
			<tr>
				<td>
					<div class="btn_cong">
						<input type="button" style="width:24px;height:24px;" value="+" class="btnupbg btnupload" name="plus" id="btnAddMore" onclick="addPurchase()" /> 
						<input type="button" style="width:24px;height:24px;" value="-" class="btnupbg btnupload " name="sub" onclick="delPurchase()" />
					</div>
				</td>
				<td style="padding-top: 5px;">
					<div class="btn_cong">
					<span>&nbsp;&nbsp;<b><?php echo $l_company_name." :"?></b>&nbsp;</span>
					</div>
				</td>
				<td >
					<div id="customerbox" >
					<div style="float:left">
						<input onkeypress="return focusOnMyInputBox(event,'name1');" type="text" size="30" value="<?=$listpurchase[0][2]?>" name="companyname" id="inputString"  style="height: 24px; width: 300px; border: 1px solid #c4c0c9;font-size: 12px;line-height: 24px;" autocomplete="off" />
						<div class="suggestionsBox" id="suggestions" style="display:none;">
							<img src="images/upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
							<div class="suggestionList" id="autoSuggestionsList">
								&nbsp;
							</div>
						</div> 						
					</div>
					<div style=" float:left; position:relative; margin-top: 5px; margin-left: -21px;z-index:999">
						<img alt="" src="images/arrow-down.png" id="menu_expand" >
					    <div id="content_menu_expand" class="passul" style="display:none"> 
					        <ul>
					        <?php 
					    		$sql="select ac_customer.CustomerName from ac_customer where ac_customer.Activest=1";
								$result = mysql_query($sql);
								if($result)
								{
									$i=0;
									while($row=mysql_fetch_array($result))
									{
										?>
										<li onmouseover="this.style.cursor='pointer'"  onmouseout="this.style.cursor='default'" onclick="clickCustomer('<?=$row['CustomerName']?>')" 
											<?php 
												if($i%2!=0){
													?>
													class="bgkhac"
													<?php 
												}
											?>
										> <?php echo $row['CustomerName'];?></li>
										<?php 
										$i++;
									}
								}
					    	?>
					        </ul>
					    </div>
					</div>
					</div>
				</td>
			</tr>
		</table>
		
          <div id="purchase">
			<table class="tcontent" cellpadding="5" cellspacing="0" id="tblView">
				<tr class="trtit">
					<td width="3%"></td>
					<td width="3%"><?php echo $l_no?></td>
					<td width="32%"><?php echo $l_product_item?></td>
					
					<td width="8%"><?php echo $l_quantity?></td>
					<td width="8%"><?php echo $l_price?></td>
					<td width="8%"><?php echo $l_price_vat?></td>
					<td width="8%"><?php echo $l_total_amount?></td>
				</tr>
				
					<?php 
					$i=1;
					$total=0;
					foreach ($listpurchase as $purchase){?>
					<tr class="my_row">
						<?php if($purchase[0]==0){?>
						<td><input type="checkbox" onclick="checkPurchase(<?=$i?>)" /></td>
						<?php }else{?>
						<td><input type="checkbox" checked="checked" onclick="checkPurchase(<?=$i?>)" /></td>
						<?php }?>
						<td><?=$i?></td>
						<td><input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($listpurchase);?>,'0')" id="<?echo "name".$i?>" name="productitem[]" onchange="chItemPurchase(this.value,<?=$i?>)" onkeyup="chItemPurchase(this.value,<?=$i?>)" style="height: 24px; width: 96%; border: 1px solid #c4c0c9;line-height: 24px;" value="<?=$purchase[1]?>" /></td>
						<td><input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($listpurchase);?>,'1')" id="<?echo "txtNumber".$i?>" name="quantity[]" onchange="chQuantityPurchase(this.value,<?=$i?>)" onkeyup="chQuantityPurchase(this.value,<?=$i?>)" style="height: 24px; width: 96%; border: 1px solid #c4c0c9;line-height: 24px;"	value="<?=$purchase[3]?>" autocomplete="off"  /></td>
						<td><div id='<?echo "price".$i;?>'><input type="text" onkeypress="return enterTable(event,this.id,<?php echo count($listpurchase);?>,'1')" id="<?echo "txtPrice".$i?>" name="price[]" onchange="chPricePurchase(this.value,<?=$i?>)"   onkeyup="chPricePurchase(this.value,<?=$i?>)" style="height: 24px; width: 96%; border: 1px solid #c4c0c9;line-height: 24px;"	value="<?=$purchase[4]?>" autocomplete="off"  /></div></td>
						<td><div id='<?echo "vat".$i;?>'><input  onkeypress="return enterTable(event,this.id,<?php echo count($listpurchase);?>,'1')" id="<?echo "txtVat".$i?>" type="text" name="pricevat[]"  onchange="chVatPurchase(this.value,<?=$i?>)" onkeyup="chVatPurchase(this.value,<?=$i?>)"  style="height: 24px; width: 96%; border: 1px solid #c4c0c9;line-height: 24px;"  value="<?=$purchase[5]?>" autocomplete="off"  /></div></td>
						<td><div id='<?echo "total".$i;?>'><input type="text" name="totalamount[]" style="height: 24px; width: 96%; border: 1px solid #c4c0c9"  value="<?=number_format($purchase[6])?>" readonly="readonly" /></div></td>
					</tr>
					<?php 
					$total=$total+$purchase[6];
					$i=$i+1;
					}?>
				
			</table>
			<table class="tcontent" cellpadding="5" cellspacing="0">
			<tr>
				<td width="20%" class="col_left"><?php echo $l_total_amount;?></td>
				<td style="text-align: left">
					<div id='all'><input type="text" readonly="readonly"  name="alltotalamount" value="<?=number_format($total)?>" style="height: 24px; width: 30%; border: 1px solid #c4c0c9;line-height: 24px;" /></div>
				</td>
			</tr>
			<tr>
				<td class="col_left"><?php echo $l_comment?></td>
				<td><textarea rows="3" cols="5" name="comment"
						style="width: 100%; border: 1px solid #c4c0c9"><?php echo $fcomment?></textarea></td>
			</tr>
		</table>
		</div>
           
	</div>
	<div id="viewtb"></div>
</form>
<div style="diplay:none">
						 <?php include 'attach/attachhidden.php';?>
				</div>
